package cn.silver.framework.log.event;

import cn.silver.framework.core.utils.DateUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.servlet.http.HttpServletRequest;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * 登录事件
 *
 * @author Silver Zhou
 */

@Data
@NoArgsConstructor
@Schema(name = "LoginEvent", title = "用户登录信息对象")
public class LoginEvent implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户主键
     */
    @Schema(title = "用户主键")
    private String userId;

    /**
     * 登录账号
     */
    @Schema(title = "登录账号")
    private String userCode;

    /**
     * 用户姓名
     */
    @Schema(title = "用户姓名")
    private String userName;

    /**
     * 客户端编码
     */
    @Schema(title = "客户端编码")
    private String clientCode;

    /**
     * 授权类型
     */
    @Schema(title = "授权类型")
    private String grantType;

    /**
     * 设备类型
     */
    @Schema(title = "设备类型")
    private String deviceType;

    /**
     * 操作系统
     */
    @Schema(title = "操作系统")
    private String os;

    /**
     * 登录IP地址
     */
    @Schema(title = "登录IP地址")
    private String ipaddr;

    /**
     * 访问时间
     */
    @Schema(title = "访问时间")
    @JsonFormat(timezone = DateUtils.TIME_ZONE, pattern = DateUtils.YYYY_MM_DD_HH_MM_SS)
    private Date loginTime;

    /**
     * 登录结果
     */
    @Schema(title = "登录结果")
    private String result;

    /**
     * 提示消息
     */
    @Schema(title = "提示消息")
    private String message;
    /**
     * 租户编号
     */
    @Schema(title = "租户编号")
    private String tenantId;

    /**
     * 请求体
     */
    private HttpServletRequest request;

    /**
     * 其他参数
     */
    private Object[] args;

}
